﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PaypalPaymentTest.Models;

namespace PaypalPaymentTest.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var model = new PurchaseModel()
            {
                ItemName = "Book",
                Amount = "500"
            };
            return View(model);
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult PayByPaypal(string itemName, string amount)
        {
            PaymentModel paypal = new PaymentModel();
            paypal.cmd = "_xclick";
            paypal.business = "albel1205@gmail.com";
            paypal.cancel_return = "";
            paypal.@return = "";//Return url after the payment was made.
            paypal.notify_url = "";
            paypal.currency_code = "USD";
            paypal.item_name = itemName;
            paypal.amount = amount;

            ViewBag.actionURl = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            
            return View(paypal);
        }

        //public ActionResult ReturnFromPaypal()
        //{

        //}
    }
}
